package com.zbkj.crmeb.member.controller;


import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.member.service.IStoreProductDiscountService;
import com.zbkj.crmeb.member.vo.StoreProductDiscountVO;
import com.zbkj.crmeb.merchant.admin.controller.AdminBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 指定商品折扣 前端控制器
 * </p>
 *
 * @author xx
 * @since 2022-05-11
 */
@RestController
@RequestMapping("/api/admin/mer/member/discount")
@Api(tags = "商户会员商品折扣")
public class StoreProductDiscountController extends AdminBaseController {
    @Autowired
    private IStoreProductDiscountService storeProductDiscountService;

    @ApiOperation(value = "商户会员折扣商品添加")
    @RequestMapping(value = "/addProductDiscount", method = RequestMethod.POST)
    public CommonResult<Object> addProductDiscount(@RequestBody StoreProductDiscountVO storeProductDiscountVO, HttpServletRequest servletRequest){
        storeProductDiscountVO.setMerId(getMerId(servletRequest));
        return storeProductDiscountService.addProductDiscount(storeProductDiscountVO) ? CommonResult.success() : CommonResult.failed();
    }

    @ApiOperation(value = "商户会员折扣商品删除")
    @RequestMapping(value = "/delProductDiscount", method = RequestMethod.POST)
    public CommonResult<Object> delProductDiscount(@RequestBody StoreProductDiscountVO storeProductDiscountVO, HttpServletRequest servletRequest){
        storeProductDiscountVO.setMerId(getMerId(servletRequest));
        return storeProductDiscountService.delProductDiscount(storeProductDiscountVO) ? CommonResult.success() : CommonResult.failed();
    }

}

